<html>
<head><meta charset="utf-8"><title>Apache Arrow ICE #64908 · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html">Apache Arrow ICE #64908</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="177251912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177251912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177251912">(Oct 03 2019 at 14:50)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="125250">@Wesley Wiser</span> have you investigated this at all?</p>



<a name="177251927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177251927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177251927">(Oct 03 2019 at 14:51)</a>:</h4>
<p>I could try to put in some effort to help, prob tomorrow</p>



<a name="177256792"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177256792" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177256792">(Oct 03 2019 at 15:38)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="116009">@nikomatsakis</span>, I have a few hours this morning to look at it. Investigating now...</p>



<a name="177260917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177260917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177260917">(Oct 03 2019 at 16:23)</a>:</h4>
<p>Can you have polymorphic promoted MIR? I thought it had to be monomorphic?</p>



<a name="177261816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177261816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177261816">(Oct 03 2019 at 16:33)</a>:</h4>
<p>I guess that's allowed since it's doing the same thing on <code>stable</code>/<code>beta</code>. The call to <code>std::mem::size_of::&lt;T::Native&gt;()</code> gets promoted to</p>
<div class="codehilite"><pre><span></span>promoted[2] in  new: usize = {
    let mut _0: usize;                   // return place in scope 0 at &lt;::core::macros::assert_eq macros&gt;:3:23: 3:32
    let mut _1: usize;                   // in scope 0 at src/main.rs:6:19: 6:51
    scope 1 {
        scope 2 {
        }
    }

    bb0: {
        _1 = const std::mem::size_of::&lt;&lt;T as ArrowPrimitiveType&gt;::Native&gt;() -&gt; bb1; // bb0[0]: scope 0 at src/main.rs:6:19: 6:51
                                         // ty::Const
                                         // + ty: fn() -&gt; usize {std::mem::size_of::&lt;&lt;T as ArrowPrimitiveType&gt;::Native&gt;}
                                         // + val: Scalar(&lt;ZST&gt;)
                                         // mir::Constant
                                         // + span: src/main.rs:6:19: 6:49
                                         // + user_ty: UserType(0)
                                         // + literal: Const { ty: fn() -&gt; usize {std::mem::size_of::&lt;&lt;T as ArrowPrimitiveType&gt;::Native&gt;}, val: Scalar(&lt;ZST&gt;) }
    }

    bb1: {
        _0 = move _1;                    // bb1[0]: scope 0 at &lt;::core::macros::assert_eq macros&gt;:3:23: 3:32
        return;                          // bb1[1]: scope 0 at &lt;::core::macros::assert_eq macros&gt;:3:23: 3:32
    }
}
</pre></div>



<a name="177264837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177264837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177264837">(Oct 03 2019 at 17:05)</a>:</h4>
<p>Made some progress. I don't have a solution yet but here's a few things that jump out to me:</p>
<p>- <a href="https://github.com/rust-lang/rust/blob/cfb6d84720019236e33872e145d187dfd6e81090/src/librustc_mir/interpret/terminator.rs#L274" target="_blank" title="https://github.com/rust-lang/rust/blob/cfb6d84720019236e33872e145d187dfd6e81090/src/librustc_mir/interpret/terminator.rs#L274">This</a> is the line that's failing because we can't normalize the type. That's not actually needed at this point because we just want to get at <code>Ty.kind</code> which doesn't need to be normalized. Changing this to just call <code>self.tcx.type_of(instance.def_id())</code> gets us slightly further along.</p>
<p>- The next thing that fails is <a href="https://github.com/rust-lang/rust/blob/cfb6d84720019236e33872e145d187dfd6e81090/src/librustc_mir/interpret/terminator.rs#L258" target="_blank" title="https://github.com/rust-lang/rust/blob/cfb6d84720019236e33872e145d187dfd6e81090/src/librustc_mir/interpret/terminator.rs#L258">this</a> where we actually try to call the intrinsic. What's interesting is that <code>M</code> is not <code>ConstPropMachine</code> which bails out of running intrinsics but a <code>CompileTimeInterpreter</code> which will try to eval intrinsics. I believe this is happening because <code>InterpCx::eval_static_to_mplace()</code> calls <code>self.tcx.const_eval_raw()</code> regardless of what the <code>M: Machine</code> is on our context. That seems fishy to me.</p>



<a name="177264855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177264855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177264855">(Oct 03 2019 at 17:05)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="116009">@nikomatsakis</span> ^^</p>



<a name="177264964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177264964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177264964">(Oct 03 2019 at 17:06)</a>:</h4>
<p>We may be able to fix this by <code>throw_inval!(TooGeneric)</code> at the right place</p>



<a name="177264972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177264972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177264972">(Oct 03 2019 at 17:06)</a>:</h4>
<p>Where ever that is... <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="177268780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Apache%20Arrow%20ICE%20%2364908/near/177268780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Apache.20Arrow.20ICE.20.2364908.html#177268780">(Oct 03 2019 at 17:48)</a>:</h4>
<p>I have a fix assuming <span class="user-mention" data-user-id="124288">@oli</span> approves :) <br>
<a href="https://github.com/rust-lang/rust/pull/65066" target="_blank" title="https://github.com/rust-lang/rust/pull/65066">https://github.com/rust-lang/rust/pull/65066</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>